home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume3 / texchk / part2 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  48.5 KB

  1. From: talcott!think!massar
  2. Subject: texchk (part 2 of 2) - syntax checker for LaTeX
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 3, Issue 64
  7. Submitted by: talcott!think!massar
  8.  
  9.  
  10. This is 'texchk', a syntax checker for the LaTeX TeX macro package.
  11.  
  12. JP Massar
  13. massar@think.com
  14. ihnp4!think!massar
  15.  
  16. ------------------------------------------------------------------------------
  17. #! /bin/sh
  18. # This is a shell archive, meaning:
  19. # 1. Remove everything above the #! /bin/sh line.
  20. # 2. Save the resulting text in a file.
  21. # 3. Execute the file with /bin/sh (not csh) to create the files:
  22. #    cmds.c
  23. #    ctools.c
  24. #    errors.c
  25. #    texchars.c
  26. #    verbatim.c
  27. # This archive created: Tue Dec 17 10:00:15 1985
  28. export PATH; PATH=/bin:$PATH
  29. echo shar: extracting "'cmds.c'" '(21192 characters)'
  30. if test -f 'cmds.c'
  31. then
  32.     echo shar: will not over-write existing file "'cmds.c'"
  33. else
  34. cat << \SHAR_EOF > 'cmds.c'
  35. #include "cmds.h"
  36.  
  37. Latex_Command Command_Table[] = {
  38.  
  39.         { 1, " ", '\0' },
  40.         { 1, "!", '1' },
  41.         { 1, "\"", '\0' },
  42.         { 1, "#", '\0' },
  43.         { 1, "$", '\0' },
  44.         { 1, "%", '\0' },
  45.         { 1, "&", '\0' },
  46.         { 1, "'", '\0' },
  47.         { 1, "(", '\0' },
  48.         { 1, ")", '\0' },
  49.         { 1, "+", '\0' },
  50.         { 1, ",", '\0' },
  51.         { 1, "-", '\0' },
  52.         { 1, ".", '\0' },
  53.         { 1, "/", '\0' },
  54.         { 1, ":", '1' },
  55.         { 1, ";", '1' },
  56.         { 1, "<", '\0' },
  57.         { 1, "=", '\0' },
  58.         { 1, ">", '\0' },
  59.         { 1, "@", '\0' },
  60.         { 2, "AA", '\0' },
  61.         { 2, "AE", '\0' },
  62.         { 4, "Alph", '\0' },
  63.         { 3, "Box", '1' },
  64.         { 5, "Delta", '1' },
  65.         { 7, "Diamond", '1' },
  66.         { 9, "Downarrow", '1' },
  67.         { 5, "Gamma", '1' },
  68.         { 1, "H", '\0' },
  69.         { 4, "Huge", '\0' },
  70.         { 2, "Im", '1' },
  71.         { 4, "Join", '1' },
  72.         { 5, "LARGE", '\0' },
  73.         { 5, "LaTeX", '\0' },
  74.         { 6, "Lambda", '1' },
  75.         { 5, "Large", '\0' },
  76.         { 9, "Leftarrow", '1' },
  77.         { 14, "Leftrightarrow", '1' },
  78.         { 13, "Longleftarrow", '1' },
  79.         { 18, "Longleftrightarrow", '1' },
  80.         { 14, "Longrightarrow", '1' },
  81.         { 1, "O", '\0' },
  82.         { 2, "OE", '\0' },
  83.         { 5, "Omega", '1' },
  84.         { 1, "P", '\0' },
  85.         { 3, "Phi", '1' },
  86.         { 2, "Pi", '1' },
  87.         { 2, "Pr", '1' },
  88.         { 3, "Psi", '1' },
  89.         { 2, "Re", '1' },
  90.         { 10, "Rightarrow", '1' },
  91.         { 5, "Roman", '\0' },
  92.         { 1, "S", '\0' },
  93.         { 5, "Sigma", '1' },
  94.         { 3, "TeX", '\0' },
  95.         { 5, "Theta", '1' },
  96.         { 7, "Uparrow", '1' },
  97.         { 11, "Updownarrow", '1' },
  98.         { 7, "Upsilon", '1' },
  99.         { 2, "Xi", '1' },
  100.         { 1, "[", '\0' },
  101.         { 1, "\\", '\0' },
  102.         { 2, "\\*", '\0' },
  103.         { 1, "]", '\0' },
  104.         { 1, "^", '\0' },
  105.         { 1, "_", '1' },
  106.         { 1, "`", '\0' },
  107.         { 1, "a", '\0' },
  108.         { 2, "aa", '\0' },
  109.         { 21, "abovedisplayshortskip", '\0' },
  110.         { 16, "abovedisplayskip", '\0' },
  111.         { 5, "acute", '1' },
  112.         { 15, "addcontentsline", '\0' },
  113.         { 7, "address", '\0' },
  114.         { 7, "address", '\0' },
  115.         { 13, "addtocontents", '\0' },
  116.         { 12, "addtocounter", '\0' },
  117.         { 11, "addtolength", '\0' },
  118.         { 9, "addvspace", '\0' },
  119.         { 13, "advancepageno", '\0' },
  120.         { 2, "ae", '\0' },
  121.         { 5, "aleph", '1' },
  122.         { 4, "alph", '\0' },
  123.         { 5, "alpha", '1' },
  124.         { 5, "amalg", '1' },
  125.         { 3, "and", '\0' },
  126.         { 5, "angle", '1' },
  127.         { 8, "appendix", '\0' },
  128.         { 6, "approx", '1' },
  129.         { 6, "arabic", '\0' },
  130.         { 6, "arccos", '1' },
  131.         { 6, "arcsin", '1' },
  132.         { 6, "arctan", '1' },
  133.         { 3, "arg", '1' },
  134.         { 11, "arraycolsep", '\0' },
  135.         { 14, "arrayrulewidth", '\0' },
  136.         { 12, "arraystretch", '\0' },
  137.         { 3, "ast", '1' },
  138.         { 5, "asymp", '1' },
  139.         { 6, "author", '\0' },
  140.         { 1, "b", '\0' },
  141.         { 9, "backslash", '1' },
  142.         { 3, "bar", '1' },
  143.         { 12, "baselineskip", '\0' },
  144.         { 15, "baselinestretch", '\0' },
  145.         { 9, "batchmode", '\0' },
  146.         { 5, "begin", '\0' },
  147.         { 12, "beginsection", '\0' },
  148.         { 21, "belowdisplayshortskip", '\0' },
  149.         { 16, "belowdisplayskip", '\0' },
  150.         { 4, "beta", '1' },
  151.         { 2, "bf", '\0' },
  152.         { 9, "bibindent", '\0' },
  153.         { 7, "bibitem", '\0' },
  154.         { 12, "bibliography", '\0' },
  155.         { 17, "bibliographystyle", '\0' },
  156.         { 6, "bigcap", '1' },
  157.         { 7, "bigcirc", '1' },
  158.         { 6, "bigcup", '1' },
  159.         { 7, "bigodot", '1' },
  160.         { 8, "bigoplus", '1' },
  161.         { 9, "bigotimes", '1' },
  162.         { 7, "bigskip", '\0' },
  163.         { 13, "bigskipamount", '\0' },
  164.         { 8, "bigsqcup", '1' },
  165.         { 15, "bigtriangledown", '1' },
  166.         { 13, "bigtriangleup", '1' },
  167.         { 8, "biguplus", '1' },
  168.         { 6, "bigvee", '1' },
  169.         { 8, "bigwedge", '1' },
  170.         { 13, "blackandwhite", '\0' },
  171.         { 4, "bmod", '1' },
  172.         { 8, "boldmath", '\0' },
  173.         { 3, "bot", '1' },
  174.         { 14, "bottomfraction", '\0' },
  175.         { 6, "bowtie", '1' },
  176.         { 5, "breve", '1' },
  177.         { 6, "bullet", '1' },
  178.         { 3, "bye", '\0' },
  179.         { 1, "c", '\0' },
  180.         { 3, "cal", '1' },
  181.         { 3, "cap", '1' },
  182.         { 7, "caption", '\0' },
  183.         { 2, "cc", '\0' },
  184.         { 4, "cdot", '1' },
  185.         { 5, "cdots", '1' },
  186.         { 9, "centering", '\0' },
  187.         { 7, "chapter", '\0' },
  188.         { 7, "chapter", '\0' },
  189.         { 5, "check", '1' },
  190.         { 3, "chi", '1' },
  191.         { 4, "circ", '1' },
  192.         { 6, "circle", '\0' },
  193.         { 7, "circle*", '\0' },
  194.         { 4, "cite", '\0' },
  195.         { 15, "cleardoublepage", '\0' },
  196.         { 9, "clearpage", '\0' },
  197.         { 9, "cleartabs", '\0' },
  198.         { 5, "cline", '\0' },
  199.         { 7, "closing", '\0' },
  200.         { 8, "clubsuit", '1' },
  201.         { 6, "colors", '\0' },
  202.         { 11, "colorslides", '\0' },
  203.         { 9, "columnsep", '\0' },
  204.         { 13, "columnseprule", '\0' },
  205.         { 4, "cong", '1' },
  206.         { 6, "coprod", '1' },
  207.         { 9, "copyright", '\0' },
  208.         { 3, "cos", '1' },
  209.         { 4, "cosh", '1' },
  210.         { 3, "cot", '1' },
  211.         { 4, "coth", '1' },
  212.         { 3, "csc", '1' },
  213.         { 3, "cup", '1' },
  214.         { 1, "d", '\0' },
  215.         { 3, "dag", '\0' },
  216.         { 6, "dagger", '1' },
  217.         { 7, "dashbox", '\0' },
  218.         { 5, "dashv", '1' },
  219.         { 4, "date", '\0' },
  220.         { 20, "dblfloatpagefraction", '\0' },
  221.         { 11, "dblfloatsep", '\0' },
  222.         { 15, "dbltextfloatsep", '\0' },
  223.         { 14, "dbltopfraction", '\0' },
  224.         { 4, "ddag", '\0' },
  225.         { 7, "ddagger", '1' },
  226.         { 4, "ddot", '1' },
  227.         { 5, "ddots", '1' },
  228.         { 3, "def", '\0' },
  229.         { 3, "deg", '1' },
  230.         { 5, "delta", '1' },
  231.         { 3, "det", '1' },
  232.         { 7, "diamond", '1' },
  233.         { 11, "diamondsuit", '1' },
  234.         { 3, "dim", '1' },
  235.         { 12, "displaystyle", '1' },
  236.         { 3, "div", '1' },
  237.         { 13, "documentstyle", '\0' },
  238.         { 12, "dosupereject", '\0' },
  239.         { 3, "dot", '1' },
  240.         { 5, "doteq", '1' },
  241.         { 7, "dotfill", '\0' },
  242.         { 9, "downarrow", '1' },
  243.         { 3, "ell", '1' },
  244.         { 2, "em", '\0' },
  245.         { 8, "emptyset", '1' },
  246.         { 4, "encl", '\0' },
  247.         { 3, "end", '\0' },
  248.         { 9, "endinsert", '\0' },
  249.         { 7, "epsilon", '1' },
  250.         { 7, "eqalign", '\0' },
  251.         { 9, "eqalignno", '\0' },
  252.         { 5, "equiv", '1' },
  253.         { 3, "eta", '1' },
  254.         { 14, "evensidemargin", '\0' },
  255.         { 6, "exists", '1' },
  256.         { 3, "exp", '1' },
  257.         { 11, "extracolsep", '\0' },
  258.         { 4, "fbox", '\0' },
  259.         { 8, "fboxrule", '\0' },
  260.         { 7, "fboxsep", '\0' },
  261.         { 4, "fill", '\0' },
  262.         { 6, "fivebf", '\0' },
  263.         { 5, "fivei", '\0' },
  264.         { 6, "fiverm", '\0' },
  265.         { 6, "fivesy", '\0' },
  266.         { 4, "flat", '1' },
  267.         { 17, "floatpagefraction", '\0' },
  268.         { 8, "floatsep", '\0' },
  269.         { 11, "flushbottom", '\0' },
  270.         { 8, "fnsymbol", '1' },
  271.         { 5, "folio", '\0' },
  272.         { 10, "footheight", '\0' },
  273.         { 8, "footline", '\0' },
  274.         { 8, "footnote", '\0' },
  275.         { 12, "footnotemark", '\0' },
  276.         { 12, "footnoterule", '\0' },
  277.         { 11, "footnotesep", '\0' },
  278.         { 12, "footnotesize", '\0' },
  279.         { 12, "footnotetext", '\0' },
  280.         { 8, "footskip", '\0' },
  281.         { 9, "footstrut", '\0' },
  282.         { 6, "forall", '1' },
  283.         { 4, "frac", '1' },
  284.         { 5, "frame", '\0' },
  285.         { 8, "framebox", '\0' },
  286.         { 13, "frenchspacing", '\0' },
  287.         { 5, "frown", '1' },
  288.         { 5, "fussy", '\0' },
  289.         { 5, "gamma", '1' },
  290.         { 3, "gcd", '1' },
  291.         { 3, "geq", '1' },
  292.         { 2, "gg", '1' },
  293.         { 8, "glossary", '\0' },
  294.         { 13, "glossaryentry", '\0' },
  295.         { 5, "grave", '1' },
  296.         { 3, "hat", '1' },
  297.         { 4, "hbar", '1' },
  298.         { 4, "hbox", '\0' },
  299.         { 10, "headheight", '\0' },
  300.         { 8, "headline", '\0' },
  301.         { 7, "headsep", '\0' },
  302.         { 9, "heartsuit", '1' },
  303.         { 5, "hfill", '\0' },
  304.         { 5, "hline", '\0' },
  305.         { 3, "hom", '1' },
  306.         { 13, "hookleftarrow", '1' },
  307.         { 14, "hookrightarrow", '1' },
  308.         { 9, "hrulefill", '\0' },
  309.         { 6, "hspace", '\0' },
  310.         { 7, "hspace*", '\0' },
  311.         { 4, "huge", '\0' },
  312.         { 11, "hyphenation", '\0' },
  313.         { 1, "i", '\0' },
  314.         { 5, "imath", '1' },
  315.         { 2, "in", '1' },
  316.         { 7, "include", '\0' },
  317.         { 11, "includeonly", '\0' },
  318.         { 6, "indent", '\0' },
  319.         { 5, "index", '\0' },
  320.         { 10, "indexentry", '\0' },
  321.         { 10, "indexspace", '\0' },
  322.         { 3, "inf", '1' },
  323.         { 5, "infty", '1' },
  324.         { 5, "input", '\0' },
  325.         { 3, "int", '1' },
  326.         { 9, "intextsep", '\0' },
  327.         { 9, "invisible", '\0' },
  328.         { 4, "iota", '1' },
  329.         { 2, "it", '\0' },
  330.         { 4, "item", '\0' },
  331.         { 10, "itemindent", '\0' },
  332.         { 7, "itemsep", '\0' },
  333.         { 1, "j", '\0' },
  334.         { 5, "jmath", '1' },
  335.         { 3, "jot", '\0' },
  336.         { 5, "kappa", '1' },
  337.         { 3, "ker", '1' },
  338.         { 4, "kill", '\0' },
  339.         { 1, "l", '\0' },
  340.         { 5, "label", '\0' },
  341.         { 10, "labelitemi", '\0' },
  342.         { 8, "labelsep", '\0' },
  343.         { 10, "labelwidth", '\0' },
  344.         { 6, "lambda", '1' },
  345.         { 6, "langle", '1' },
  346.         { 5, "large", '\0' },
  347.         { 5, "lceil", '1' },
  348.         { 5, "ldots", '1' },
  349.         { 7, "leadsto", '1' },
  350.         { 4, "left", '1' },
  351.         { 9, "leftarrow", '1' },
  352.         { 7, "lefteqn", '1' },
  353.         { 15, "leftharpoondown", '1' },
  354.         { 13, "leftharpoonup", '1' },
  355.         { 10, "leftmargin", '\0' },
  356.         { 11, "leftmargini", '\0' },
  357.         { 12, "leftmarginii", '\0' },
  358.         { 13, "leftmarginiii", '\0' },
  359.         { 12, "leftmarginiv", '\0' },
  360.         { 11, "leftmarginv", '\0' },
  361.         { 12, "leftmarginvi", '\0' },
  362.         { 14, "leftrightarrow", '1' },
  363.         { 3, "leq", '1' },
  364.         { 10, "leqalignno", '\0' },
  365.         { 6, "lfloor", '1' },
  366.         { 2, "lg", '1' },
  367.         { 3, "lhd", '1' },
  368.         { 3, "lim", '1' },
  369.         { 6, "liminf", '1' },
  370.         { 6, "limsup", '1' },
  371.         { 4, "line", '\0' },
  372.         { 9, "linebreak", '\0' },
  373.         { 13, "linethickness", '\0' },
  374.         { 9, "linewidth", '\0' },
  375.         { 13, "listoffigures", '\0' },
  376.         { 12, "listoftables", '\0' },
  377.         { 13, "listparindent", '\0' },
  378.         { 2, "ll", '1' },
  379.         { 2, "ln", '1' },
  380.         { 4, "load", '\0' },
  381.         { 3, "log", '1' },
  382.         { 13, "longleftarrow", '1' },
  383.         { 18, "longleftrightarrow", '1' },
  384.         { 10, "longmapsto", '1' },
  385.         { 14, "longrightarrow", '1' },
  386.         { 13, "magnification", '\0' },
  387.         { 7, "makebox", '\0' },
  388.         { 12, "makefootline", '\0' },
  389.         { 12, "makeglossary", '\0' },
  390.         { 12, "makeheadline", '\0' },
  391.         { 9, "makeindex", '\0' },
  392.         { 9, "makelabel", '\0' },
  393.         { 10, "makelabels", '\0' },
  394.         { 9, "maketitle", '\0' },
  395.         { 6, "mapsto", '1' },
  396.         { 9, "marginpar", '\0' },
  397.         { 13, "marginparpush", '\0' },
  398.         { 12, "marginparsep", '\0' },
  399.         { 14, "marginparwidth", '\0' },
  400.         { 8, "markboth", '\0' },
  401.         { 9, "markright", '\0' },
  402.         { 10, "mathindent", '\0' },
  403.         { 3, "max", '1' },
  404.         { 4, "mbox", '\0' },
  405.         { 7, "medskip", '\0' },
  406.         { 13, "medskipamount", '\0' },
  407.         { 3, "mho", '1' },
  408.         { 3, "mid", '1' },
  409.         { 9, "midinsert", '\0' },
  410.         { 3, "min", '1' },
  411.         { 3, "mit", '1' },
  412.         { 6, "models", '1' },
  413.         { 2, "mp", '1' },
  414.         { 2, "mu", '1' },
  415.         { 11, "multicolumn", '\0' },
  416.         { 8, "multiput", '\0' },
  417.         { 5, "nabla", '1' },
  418.         { 7, "natural", '1' },
  419.         { 7, "nearrow", '1' },
  420.         { 3, "neg", '1' },
  421.         { 3, "neq", '1' },
  422.         { 10, "newcommand", '\0' },
  423.         { 10, "newcounter", '\0' },
  424.         { 14, "newenvironment", '\0' },
  425.         { 7, "newfont", '\0' },
  426.         { 9, "newlength", '\0' },
  427.         { 7, "newline", '\0' },
  428.         { 7, "newpage", '\0' },
  429.         { 10, "newsavebox", '\0' },
  430.         { 10, "newtheorem", '\0' },
  431.         { 2, "ni", '1' },
  432.         { 6, "nocite", '\0' },
  433.         { 7, "nofiles", '\0' },
  434.         { 8, "noindent", '\0' },
  435.         { 11, "nolinebreak", '\0' },
  436.         { 16, "nonfrenchspacing", '\0' },
  437.         { 8, "nonumber", '\0' },
  438.         { 11, "nopagebreak", '\0' },
  439.         { 13, "nopagenumbers", '\0' },
  440.         { 12, "normalbottom", '\0' },
  441.         { 15, "normalmarginpar", '\0' },
  442.         { 10, "normalsize", '\0' },
  443.         { 3, "not", '1' },
  444.         { 2, "nu", '1' },
  445.         { 10, "numberline", '\0' },
  446.         { 7, "nwarrow", '1' },
  447.         { 1, "o", '1' },
  448.         { 13, "oddsidemargin", '\0' },
  449.         { 4, "odot", '1' },
  450.         { 2, "oe", '\0' },
  451.         { 4, "oint", '1' },
  452.         { 8, "oldstyle", '\0' },
  453.         { 5, "omega", '1' },
  454.         { 6, "ominus", '1' },
  455.         { 9, "onecolumn", '\0' },
  456.         { 9, "onlynotes", '\0' },
  457.         { 10, "onlyslides", '\0' },
  458.         { 7, "opening", '\0' },
  459.         { 5, "oplus", '\0' },
  460.         { 6, "oslash", '1' },
  461.         { 6, "otimes", '1' },
  462.         { 6, "output", '\0' },
  463.         { 4, "oval", '\0' },
  464.         { 9, "overbrace", '\0' },
  465.         { 8, "overline", '\0' },
  466.         { 8, "pagebody", '\0' },
  467.         { 9, "pagebreak", '\0' },
  468.         { 12, "pagecontents", '\0' },
  469.         { 10, "pageinsert", '\0' },
  470.         { 6, "pageno", '\0' },
  471.         { 13, "pagenumbering", '\0' },
  472.         { 7, "pageref", '\0' },
  473.         { 9, "pagestyle", '\0' },
  474.         { 3, "par", '\0' },
  475.         { 9, "paragraph", '\0' },
  476.         { 8, "parallel", '1' },
  477.         { 6, "parbox", '\0' },
  478.         { 9, "parindent", '\0' },
  479.         { 6, "parsep", '\0' },
  480.         { 7, "parskip", '\0' },
  481.         { 4, "part", '\0' },
  482.         { 7, "partial", '1' },
  483.         { 9, "partopsep", '\0' },
  484.         { 4, "perp", '1' },
  485.         { 3, "phi", '1' },
  486.         { 2, "pi", '1' },
  487.         { 11, "plainoutput", '\0' },
  488.         { 2, "pm", '1' },
  489.         { 4, "pmod", '1' },
  490.         { 7, "poptabs", '\0' },
  491.         { 6, "pounds", '\0' },
  492.         { 4, "prec", '1' },
  493.         { 6, "preceq", '1' },
  494.         { 5, "prime", '1' },
  495.         { 4, "prod", '1' },
  496.         { 6, "propto", '1' },
  497.         { 7, "protect", '\0' },
  498.         { 2, "ps", '\0' },
  499.         { 3, "psi", '1' },
  500.         { 8, "pushtabs", '\0' },
  501.         { 3, "put", '\0' },
  502.         { 12, "raggedbottom", '\0' },
  503.         { 12, "raggedbottom", '\0' },
  504.         { 10, "raggedleft", '\0' },
  505.         { 11, "raggedright", '\0' },
  506.         { 8, "raisebox", '\0' },
  507.         { 6, "rangle", '1' },
  508.         { 5, "rceil", '1' },
  509.         { 3, "ref", '\0' },
  510.         { 14, "refstepcounter", '\0' },
  511.         { 12, "renewcommand", '\0' },
  512.         { 16, "renewenvironment", '\0' },
  513.         { 16, "reversemarginpar", '\0' },
  514.         { 6, "rfloor", '1' },
  515.         { 3, "rhd", '1' },
  516.         { 3, "rho", '1' },
  517.         { 5, "right", '1' },
  518.         { 10, "rightarrow", '1' },
  519.         { 16, "rightharpoondown", '1' },
  520.         { 14, "rightharpoonup", '1' },
  521.         { 17, "rightleftharpoons", '1' },
  522.         { 11, "rightmargin", '\0' },
  523.         { 2, "rm", '\0' },
  524.         { 5, "roman", '\0' },
  525.         { 4, "rule", '\0' },
  526.         { 8, "samepage", '\0' },
  527.         { 7, "savebox", '\0' },
  528.         { 4, "sbox", '\0' },
  529.         { 2, "sc", '\0' },
  530.         { 10, "scriptfont", '\0' },
  531.         { 16, "scriptscriptfont", '\0' },
  532.         { 17, "scriptscriptstyle", '1' },
  533.         { 10, "scriptsize", '\0' },
  534.         { 11, "scriptstyle", '1' },
  535.         { 7, "searrow", '1' },
  536.         { 3, "sec", '1' },
  537.         { 7, "section", '\0' },
  538.         { 10, "setcounter", '\0' },
  539.         { 9, "setlength", '\0' },
  540.         { 8, "setminus", '1' },
  541.         { 7, "settabs", '\0' },
  542.         { 10, "settowidth", '\0' },
  543.         { 7, "sevenbf", '\0' },
  544.         { 6, "seveni", '\0' },
  545.         { 7, "sevensy", '\0' },
  546.         { 2, "sf", '\0' },
  547.         { 5, "sharp", '1' },
  548.         { 10, "shortstack", '\0' },
  549.         { 5, "sigma", '1' },
  550.         { 9, "signature", '\0' },
  551.         { 9, "signature", '\0' },
  552.         { 3, "sim", '1' },
  553.         { 5, "simeq", '1' },
  554.         { 3, "sin", '1' },
  555.         { 4, "sinh", '1' },
  556.         { 2, "sl", '\0' },
  557.         { 6, "sloppy", '\0' },
  558.         { 5, "small", '\0' },
  559.         { 9, "smallskip", '\0' },
  560.         { 15, "smallskipamount", '\0' },
  561.         { 5, "smile", '\0' },
  562.         { 5, "space", '\0' },
  563.         { 9, "spadesuit", '1' },
  564.         { 5, "sqcap", '1' },
  565.         { 5, "sqcup", '1' },
  566.         { 4, "sqrt", '1' },
  567.         { 8, "sqsubset", '1' },
  568.         { 10, "sqsubseteq", '1' },
  569.         { 8, "sqsupset", '1' },
  570.         { 10, "sqsupseteq", '1' },
  571.         { 2, "ss", '\0' },
  572.         { 8, "stackrel", '1' },
  573.         { 4, "star", '1' },
  574.         { 11, "stepcounter", '\0' },
  575.         { 4, "stop", '\0' },
  576.         { 7, "stretch", '\0' },
  577.         { 7, "subitem", '\0' },
  578.         { 12, "subparagraph", '\0' },
  579.         { 10, "subsection", '\0' },
  580.         { 6, "subset", '1' },
  581.         { 8, "subseteq", '1' },
  582.         { 10, "subsubitem", '\0' },
  583.         { 13, "subsubsection", '\0' },
  584.         { 4, "succ", '1' },
  585.         { 6, "succeq", '1' },
  586.         { 3, "sum", '1' },
  587.         { 3, "sup", '1' },
  588.         { 6, "supset", '1' },
  589.         { 8, "supseteq", '1' },
  590.         { 4, "surd", '1' },
  591.         { 7, "swarrow", '1' },
  592.         { 6, "symbol", '\0' },
  593.         { 1, "t", '\0' },
  594.         { 8, "tabalign", '\0' },
  595.         { 10, "tabbingsep", '\0' },
  596.         { 9, "tabcolsep", '\0' },
  597.         { 15, "tableofcontents", '\0' },
  598.         { 4, "tabs", '\0' },
  599.         { 8, "tabsdone", '\0' },
  600.         { 6, "tabset", '\0' },
  601.         { 3, "tan", '1' },
  602.         { 4, "tanh", '1' },
  603.         { 3, "tau", '1' },
  604.         { 4, "teni", '\0' },
  605.         { 12, "textfloatsep", '\0' },
  606.         { 8, "textfont", '\0' },
  607.         { 12, "textfraction", '\0' },
  608.         { 10, "textheight", '\0' },
  609.         { 9, "textstyle", '1' },
  610.         { 9, "textwidth", '\0' },
  611.         { 6, "thanks", '\0' },
  612.         { 3, "the", '\0' },
  613.         { 7, "thepage", '\0' },
  614.         { 5, "theta", '1' },
  615.         { 10, "thicklines", '\0' },
  616.         { 9, "thinlines", '\0' },
  617.         { 13, "thispagestyle", '\0' },
  618.         { 5, "tilde", '1' },
  619.         { 5, "times", '1' },
  620.         { 4, "tiny", '\0' },
  621.         { 5, "title", '\0' },
  622.         { 5, "title", '\0' },
  623.         { 5, "today", '\0' },
  624.         { 3, "top", '1' },
  625.         { 11, "topfraction", '\0' },
  626.         { 6, "topins", '\0' },
  627.         { 9, "topinsert", '\0' },
  628.         { 9, "topmargin", '\0' },
  629.         { 6, "topsep", '\0' },
  630.         { 7, "topskip", '\0' },
  631.         { 8, "triangle", '1' },
  632.         { 12, "triangleleft", '1' },
  633.         { 13, "triangleright", '1' },
  634.         { 2, "tt", '\0' },
  635.         { 9, "twocolumn", '\0' },
  636.         { 6, "typein", '\0' },
  637.         { 7, "typeout", '\0' },
  638.         { 1, "u", '\0' },
  639.         { 10, "unboldmath", '\0' },
  640.         { 10, "underbrace", '\0' },
  641.         { 9, "underline", '\0' },
  642.         { 10, "unitlength", '\0' },
  643.         { 5, "unlhd", '1' },
  644.         { 5, "unrhd", '1' },
  645.         { 7, "uparrow", '1' },
  646.         { 11, "updownarrow", '1' },
  647.         { 5, "uplus", '1' },
  648.         { 7, "upsilon", '1' },
  649.         { 6, "usebox", '\0' },
  650.         { 10, "usecounter", '\0' },
  651.         { 1, "v", '\0' },
  652.         { 5, "value", '\0' },
  653.         { 10, "varepsilon", '1' },
  654.         { 6, "varphi", '1' },
  655.         { 5, "varpi", '1' },
  656.         { 6, "varrho", '1' },
  657.         { 8, "varsigma", '1' },
  658.         { 8, "vartheta", '1' },
  659.         { 4, "vbox", '\0' },
  660.         { 5, "vdash", '1' },
  661.         { 5, "vdots", '1' },
  662.         { 3, "vec", '1' },
  663.         { 6, "vector", '\0' },
  664.         { 3, "vee", '1' },
  665.         { 4, "verb", '\0' },
  666.         { 5, "verb*", '\0' },
  667.         { 5, "vfill", '\0' },
  668.         { 9, "vfootnote", '\0' },
  669.         { 5, "vline", '\0' },
  670.         { 6, "vspace", '\0' },
  671.         { 7, "vspace*", '\0' },
  672.         { 5, "wedge", '1' },
  673.         { 7, "widehat", '1' },
  674.         { 9, "widetilde", '1' },
  675.         { 2, "wp", '1' },
  676.         { 2, "wr", '1' },
  677.         { 2, "xi", '1' },
  678.         { 4, "zeta", '1' },
  679.         { 1, "{", '\0' },
  680.         { 1, "|", '1' },
  681.         { 1, "}", '\0' },
  682.         { 1, "~", '\0' }
  683.  
  684.    };
  685.  
  686.  
  687. char *Math_Environments[] = {   
  688.    
  689.      "math",
  690.      "displaymath",
  691.      "equation",
  692.      "eqnarray",
  693.      "eqnarray*",
  694.      0
  695.  
  696.   };
  697.    
  698.  
  699. int is_math_environment (keyword) char *keyword;  
  700. {
  701.   char **mathenvs = Math_Environments;
  702.   while (*mathenvs != 0) {
  703.     if (0 == strcmp(*mathenvs,keyword)) return(1);
  704.     mathenvs++;
  705.   }
  706.   return(0);
  707. }
  708.  
  709.   
  710. int command_lookup (command) char *command;
  711.  
  712. {
  713.   int head = 0;
  714.   int tail = COMMAND_TABLE_SIZE - 1;
  715.   int mid,result;
  716.         
  717.   while (head <= tail) {
  718.     mid = head + (tail - head) / 2;
  719.     result = strcmp(command,Command_Table[mid].cmd);
  720.     if (result > 0)
  721.        head = mid + 1;
  722.     else if (result < 0)
  723.        tail = mid - 1;
  724.     else
  725.        return(mid);
  726.   }
  727.   return(NOT_FOUND);
  728. }
  729.   
  730. SHAR_EOF
  731. if test 21192 -ne "`wc -c < 'cmds.c'`"
  732. then
  733.     echo shar: error transmitting "'cmds.c'" '(should have been 21192 characters)'
  734. fi
  735. fi
  736. echo shar: extracting "'ctools.c'" '(19032 characters)'
  737. if test -f 'ctools.c'
  738. then
  739.     echo shar: will not over-write existing file "'ctools.c'"
  740. else
  741. cat << \SHAR_EOF > 'ctools.c'
  742. /* -*- Mode: C; Package: (CTOOLS C) -*- */
  743.  
  744. #include <ctype.h>
  745. #include <stdio.h>
  746.  
  747. /* if your system doesn't have either string.h or strings.h you may have to */
  748. /* declare the string functions yourself */
  749. #ifdef BSD42
  750. #include <strings.h>
  751. #else
  752. #include <string.h>
  753. #endif
  754.  
  755. #ifdef TMC
  756. #include "newctools.h"
  757. #else
  758. #include "ctools.h"
  759. #endif
  760.  
  761. /* miscellaneous fairly primitive routines that deal with characters, */
  762. /* strings, memory, simple input and pathnames. */
  763.  
  764.  
  765. /* Author:  JP Massar */
  766. /* Thinking Machines Corporation */
  767.  
  768. /* Included routines:
  769.  
  770.    emalloc
  771.    anewstr
  772.    
  773.    copy
  774.    fill
  775.    
  776.    to_upper_if_lower
  777.    to_lower_if_upper
  778.    
  779.    buffconcat
  780.    nbuffconcat
  781.    
  782.    slcompare
  783.    slge_compare
  784.    nocase_compare
  785.    
  786.    strfind
  787.    strncfind
  788.    strsearch
  789.    strncsearch
  790.    
  791.    yes_or_no_check
  792.    
  793.    remove_excess_blanks
  794.    
  795.    all_digits
  796.    all_whitespace
  797.    all_uppercase
  798.    all_lowercase
  799.    all_alphabetic
  800.    all_alphanumeric
  801.    all_ascii
  802.    
  803.    str_to_pos_int
  804.    
  805.    sreverse
  806.    ip_sreverse
  807.         
  808.    temp_path
  809.    perm_path
  810.    make_path_numeric_extension
  811.    make_path
  812.    just_filename
  813.    
  814.    read_yes_or_no
  815.    getline
  816.    getlines
  817.    ngetlines
  818.    getfile
  819.    ngetfile
  820.    read_file_into_buffer
  821.    efopen
  822.  
  823.    check_int
  824.    check_string
  825.    
  826. */
  827.    
  828.  
  829. extern char *malloc();
  830.  
  831.  
  832. char *emalloc (space) int space;
  833.  
  834. /* allocate 'space' bytes, die if we have run out of memory. */
  835.  
  836. {
  837.   char *rval;        
  838.   if (space < 0) {
  839.      fprintf(stderr,"Fatal error: argument to emalloc < 0\n");
  840.      exit(-1);
  841.   }
  842.   if (0 == (rval = malloc((unsigned) space))) {
  843.      fprintf(stderr,"Fatal error:  No more memory\n");
  844.      exit(-1);
  845.   }
  846.   return(rval);
  847. }  
  848.  
  849.  
  850. char *anewstr (astring) char *astring;
  851.  
  852. /* allocate space for and then copy a string.  Returns pointer to */
  853. /* new string. */
  854.  
  855. {        
  856.   char *newstr;
  857.   newstr = emalloc(strlen(astring)+1);
  858.   strcpy(newstr,astring);
  859.   return(newstr);
  860. }
  861.  
  862.  
  863. copy (dest,src,n)
  864.  
  865.   /* copy n bytes */
  866.  
  867.   register char *dest,*src;
  868.   register int n;
  869.  
  870.   { register int j = 0;
  871.     while (j++ < n) *dest++ = *src++; 
  872.   }
  873.  
  874.  
  875. fill (addr,ch,n)
  876.  
  877.   /* fill n sequential bytes with 'ch' */
  878.  
  879.   register char *addr;
  880.   register char ch;
  881.   register int n;
  882.   
  883.   { register int j = 0;
  884.     while (j++ < n) *addr++ = ch;
  885.   }
  886.  
  887.  
  888. to_upper_if_lower (ch)
  889.  
  890.   char ch;
  891.  
  892.   { return(islower(ch) ? toupper(ch) : ch); }
  893.  
  894.  
  895. to_lower_if_upper (ch)
  896.  
  897.   char ch;
  898.  
  899.   { return(isupper(ch) ? tolower(ch) : ch); }
  900.  
  901.  
  902. buffconcat (buffer,s1,s2) 
  903.  
  904.   /* concatenate two null terminated strings into a buffer. */
  905.  
  906.   char *buffer, *s1, *s2;
  907.   
  908.   { while (*s1 != '\0') *buffer++ = *s1++;
  909.     while (*s2 != '\0') *buffer++ = *s2++;
  910.     *buffer = '\0';
  911.   }
  912.  
  913.  
  914. nbuffconcat (buffer,n,s1,s2,s3,s4,s5,s6)
  915.  
  916.   /* concatenates up to 6 strings into a buffer.  Returns -1 if n */
  917.   /* is not reasonable, otherwise returns 0. */
  918.  
  919.   char *buffer;
  920.   int n;
  921.   char *s1,*s2,*s3,*s4,*s5,*s6;
  922.  
  923. {
  924.   register char *b;
  925.   register char *s;
  926.   int i;
  927.   b = buffer;
  928.   if (n < 1 || n > 6) return(-1);
  929.   for (i = 1; i <= 6; i++) {
  930.       if (i > n) break;
  931.       switch (i) {
  932.         case 1 : s = s1; break;
  933.         case 2 : s = s2; break;
  934.         case 3 : s = s3; break;
  935.         case 4 : s = s4; break;
  936.         case 5 : s = s5; break;
  937.         case 6 : s = s6; break;
  938.       }
  939.       while (*s != '\0') *b++ = *s++;
  940.   }
  941.   *b = '\0';
  942.   return(0);
  943. }
  944.  
  945.  
  946. slcompare (s1,l1,s2,l2)
  947.  
  948.   /* compare strings with possible nulls in them given their lengths */
  949.   /* only returns EQUAL (0) or NOT EQUAL (-1) */
  950.  
  951.   char *s1;
  952.   int l1;
  953.   char *s2;
  954.   int l2;
  955.  
  956.   { int j;
  957.     if (l1 != l2) return(-1);
  958.     j = 0;
  959.     while (j++ < l1) 
  960.       if (*s1++ != *s2++) return(-1);
  961.     return(0);
  962.   }
  963.  
  964.   
  965. slge_compare (s1,l1,s2,l2)
  966.  
  967.   /* returns -1 if s1 < s2; 1 if s2 < s1; 0 if s1 = s2 */
  968.   /* ignores nulls in the strings */
  969.  
  970.   char *s1;
  971.   int l1;
  972.   char *s2;
  973.   int l2;
  974.  
  975.   { int j,len;
  976.     j = 0;
  977.     len = l2 > l1 ? l1 : l2;
  978.     while (j++ < len) {
  979.       if (*s1 != *s2) 
  980.          return((*s1 < *s2) ? -1 : 1);
  981.       s1++;   
  982.       s2++;
  983.     }  
  984.     return((l2 == l1) ? 0 : ((l1 < l2) ? -1 : 1));
  985.   }
  986.  
  987. nocase_compare (s1,l1,s2,l2)
  988.  
  989.   /* treats nulls as normal characters.  Returns same as slge_compare */
  990.  
  991.   char *s1;
  992.   int l1;
  993.   char *s2;
  994.   int l2;
  995.  
  996.   { int j,len,ch1,ch2;
  997.     j = 0;
  998.     len = l2 > l1 ? l1 : l2;
  999.     while (j++ < len) {
  1000.       ch1 = to_upper_if_lower(*s1++);
  1001.       ch2 = to_upper_if_lower(*s2++);
  1002.       if (ch1 != ch2) {
  1003.          return((ch1 < ch2) ? -1 : 1);
  1004.       }
  1005.     }  
  1006.     return((l2 == l1) ? 0 : ((l1 < l2) ? -1 : 1));
  1007.   }
  1008.  
  1009.  
  1010. char *strfind(s1,s2,fast)  
  1011.   
  1012.   register char *s1;
  1013.   char *s2;
  1014.   Bool fast;
  1015.   
  1016. {  
  1017.   register int len1,len2;
  1018.   len2 = strlen(s2);
  1019.   if (fast) {
  1020.      while (*s1 != '\0')
  1021.        if (0 == strncmp(s1++,s2,len2)) return(s1-1);
  1022.   }  
  1023.   else {
  1024.      len1 = strlen(s1);
  1025.      while (len1 >= len2) {
  1026.        if (0 == strncmp(s1++,s2,len2)) return(s1-1);
  1027.        len1--;
  1028.      }
  1029.   }
  1030.   return(0);
  1031. }     
  1032.  
  1033.  
  1034. char *strncfind(s1,s2,fast)
  1035.  
  1036.   register char *s1;
  1037.   char *s2;
  1038.   Bool fast;
  1039.   
  1040. {  
  1041.   register int len1,len2;
  1042.   len2 = strlen(s2);
  1043.   if (fast) {
  1044.      while (*s1 != '\0')
  1045.        if (0 == nocase_compare(s1++,len2,s2,len2)) return(s1-1);
  1046.   }
  1047.   else {
  1048.      len1 = strlen(s1);
  1049.      while (len1 >= len2) {
  1050.        if (0 == nocase_compare(s1++,len2,s2,len2)) return(s1-1);
  1051.        len1--;
  1052.      }
  1053.   }
  1054.   return(0);
  1055. }  
  1056.  
  1057.   
  1058. char *strsearch(s1,s1len,s2,s2len)
  1059.  
  1060.   /* do a substring search without noticing nulls */
  1061.   /* finds s2 in s1, returns pointer into s1 or 0 */
  1062.  
  1063.   register char *s1, *s2;
  1064.   register int s1len,s2len;
  1065.   
  1066.   {  register char *pc;
  1067.      register char *bound;
  1068.      register char *pctemp;
  1069.      register char *s2temp;
  1070.      register int j;
  1071.  
  1072.      bound = s1 + s1len - s2len;
  1073.      for (pc = s1; pc <= bound; pc++) {
  1074.          pctemp = pc;
  1075.          s2temp = s2;
  1076.          for (j = 0; j < s2len; j++)
  1077.              if (*pctemp++ != *s2temp++) goto not_here;
  1078.          return(pc);       
  1079.          not_here :
  1080.          continue;
  1081.      }    
  1082.      return(0);
  1083. }
  1084.  
  1085.  
  1086. char *strncsearch(s1,s1len,s2,s2len)
  1087.  
  1088.   /* do a substring search without noticing nulls */
  1089.   /* finds s2 in s1, returns pointer into s1 or 0 */
  1090.   /* case independent */
  1091.  
  1092.   register char *s1, *s2;
  1093.   register int s1len,s2len;
  1094.   
  1095.   {  register char *pc;
  1096.      register char *bound;
  1097.      register char *pctemp;
  1098.      register char *s2temp;
  1099.      register int j;
  1100.      char ch1, ch2;
  1101.  
  1102.      bound = s1 + s1len - s2len;
  1103.      for (pc = s1; pc <= bound; pc++) {
  1104.          pctemp = pc;
  1105.          s2temp = s2;
  1106.          for (j = 0; j < s2len; j++) {
  1107.              ch1 = *pctemp++;
  1108.              ch2 = *s2temp++;
  1109.              if (to_upper_if_lower(ch1) != to_upper_if_lower(ch2))
  1110.                 goto not_here;
  1111.          }
  1112.          return(pc);       
  1113.          not_here :
  1114.          continue;
  1115.      }    
  1116.      return(0);
  1117. }
  1118.  
  1119.  
  1120. int remove_excess_blanks (newstring,oldstring) 
  1121.  
  1122.   /* it is assumed that newstring is as long as oldstring if necessary */
  1123.  
  1124.   char *newstring,*oldstring;
  1125.  
  1126. {
  1127.   int count = 0;
  1128.   int space_found = 0;
  1129.  
  1130.   /* skip over all blanks at beginning */
  1131.   
  1132.   if (*oldstring == ' ') {
  1133.      while (*oldstring == ' ') oldstring++;
  1134.   }
  1135.  
  1136.   while (*oldstring != '\0') {
  1137.         if (space_found && *oldstring == ' ') {
  1138.            oldstring++;
  1139.            continue;
  1140.         }
  1141.         space_found = (*oldstring == ' ');
  1142.         *newstring++ = *oldstring++;
  1143.         count++;
  1144.   }
  1145.  
  1146.   *newstring = '\0';
  1147.   if (count > 0 && *(newstring - 1) == ' ') {
  1148.      count--;
  1149.      *(newstring - 1) = '\0';
  1150.   }
  1151.  
  1152.   return(count);
  1153.  
  1154. }
  1155.  
  1156.  
  1157. yes_or_no_check (astring) char *astring;
  1158.  
  1159. /* returns 1 if yes, 0 if no, -1 if neither */
  1160. /* works for 'Y' 'YES' 'NO' 'N' in any capitalization */
  1161.  
  1162. {  
  1163.   int len;
  1164.   len = strlen(astring);
  1165.   if (len == 0 || len > 3) return(-1);
  1166.   if (0 == nocase_compare(astring,len,"YES",3) || 
  1167.       0 == nocase_compare(astring,len,"Y",1))
  1168.      return(1);
  1169.   if (0 == nocase_compare(astring,len,"NO",2) || 
  1170.       0 == nocase_compare(astring,len,"N",1))
  1171.      return(0);
  1172.   return(-1);
  1173. }
  1174.  
  1175.  
  1176. Bool all_digits (astring) char *astring;
  1177.  
  1178. /* test whether every character is a digit (0-9) */
  1179.  
  1180. {
  1181.   while (*astring != '\0') 
  1182.     if (!isdigit(*astring++)) return(F);
  1183.   return(T);
  1184. }
  1185.  
  1186.  
  1187. Bool all_whitespace (astring) char *astring;
  1188.  
  1189. /* test whether every character is a blank or a tab */
  1190.  
  1191. {
  1192.   register char ch;
  1193.   while ((ch = *astring++) != '\0') {
  1194.     if (ch == ' ' || ch == '\t') continue;
  1195.     return(F);
  1196.   }
  1197.   return(T);
  1198. }
  1199.  
  1200. Bool all_uppercase(astring) char *astring;
  1201. {
  1202.   register char ch;
  1203.   while ((ch = *astring++) != '\0') {
  1204.     if (!isupper(ch)) return(F);
  1205.   }
  1206.   return(T);
  1207. }
  1208.  
  1209. Bool all_lowercase(astring) char *astring;
  1210. {
  1211.   register char ch;
  1212.   while ((ch = *astring++) != '\0') {
  1213.     if (!islower(ch)) return(F);
  1214.   }
  1215.   return(T);
  1216. }
  1217.  
  1218. Bool all_alphabetic(astring) char *astring;
  1219. {
  1220.   register char ch;
  1221.   while ((ch = *astring++) != '\0') {
  1222.     if (!isalpha(ch)) return(F);
  1223.   }
  1224.   return(T);
  1225. }
  1226.  
  1227. Bool all_ascii(astring) char *astring;
  1228. {
  1229.   register char ch;
  1230.   while ((ch = *astring++) != '\0') {
  1231.     if (!isascii(ch)) return(F);
  1232.   }
  1233.   return(T);
  1234. }
  1235.  
  1236. Bool all_alphanumeric(astring) char *astring;
  1237. {
  1238.   register char ch;
  1239.   while ((ch = *astring++) != '\0') {
  1240.     if (!isalnum(ch)) return(F);
  1241.   }
  1242.   return(T);
  1243. }
  1244.  
  1245. int str_to_pos_int (astring,low,high) char *astring; int low,high;
  1246.  
  1247.   /* returns -1 if *astring is not composed of digits. */
  1248.   /* returns -2 if the integer is out of range. */
  1249.   /* treats all digit strings as decimal. */
  1250.  
  1251. {
  1252.   int value,len,maxlen,j;
  1253.   maxlen = strlen(MAXINTSTR);
  1254.   len = strlen(astring);
  1255.   if (!all_digits(astring)) return(-1);
  1256.   if (len > maxlen) return(-2);
  1257.   if (len == maxlen) {
  1258.      if (1 == strcmp(astring,MAXINTSTR)) return(-2);
  1259.   }
  1260.   for (j = 0; j < len-1; j++) {
  1261.       if (*astring != '0') break;
  1262.       astring++;
  1263.   }
  1264.   sscanf(astring,"%d",&value);
  1265.   if (value < low || value > high) return(-2);
  1266.   return(value);
  1267. }
  1268.  
  1269.  
  1270. int sreverse (buffer,astring) char *buffer, *astring;
  1271. {
  1272.   register int last = strlen(astring);
  1273.   buffer[last--] = '\0';
  1274.   while (last >= 0) buffer[last--] = *astring++;
  1275. }
  1276.  
  1277. char * ip_sreverse (astring) char *astring;
  1278. {
  1279.   register int last = strlen(astring) - 1;
  1280.   register int first = 0;
  1281.   register char ch;
  1282.   while (first < last) {
  1283.     ch = astring[first];
  1284.     astring[first++] = astring[last];
  1285.     astring[last--] = ch;
  1286.   }
  1287.   return(astring);
  1288. }
  1289.  
  1290.  
  1291.  
  1292. static char pathbuffer[PATH_MAXPATHLEN];
  1293.  
  1294.  
  1295. char *temp_path (dir,filename) char *dir; char *filename;
  1296.  
  1297. {
  1298.   return(make_path(dir,filename,"",F));
  1299. }
  1300.  
  1301.  
  1302. char *perm_path (dir,filename) char *dir; char *filename;
  1303.  
  1304. {
  1305.   return(make_path(dir,filename,"",T));
  1306. }
  1307.  
  1308.  
  1309. char *make_path_numeric_extension (dir,filename,extension,perm)
  1310.  
  1311.   char *dir, *filename;
  1312.   int extension;
  1313.   Bool perm;
  1314.  
  1315. {
  1316.   char buffer[20];
  1317.   sprintf(buffer,"%d",extension);
  1318.   return(make_path(dir,filename,buffer,perm));
  1319. }
  1320.  
  1321.  
  1322. char *make_path (dir,filename,extension,perm)
  1323.  
  1324.   char *dir, *filename, *extension;
  1325.   Bool perm;
  1326.  
  1327. {
  1328.   char *rval;
  1329.   if (!perm && (strlen(dir) + 1 + strlen(filename) + strlen(extension) + 1 >=
  1330.                 PATH_MAXPATHLEN)) {
  1331.      return((char *) 0);
  1332.   }
  1333.   nbuffconcat(pathbuffer,4,dir,"/",filename,extension);
  1334.   if (!perm) return(pathbuffer);
  1335.   rval = emalloc(strlen(pathbuffer) + 1);  
  1336.   strcpy(rval,pathbuffer);
  1337.   return(rval);
  1338. }
  1339.  
  1340.  
  1341. char *just_filename (path,new,perm) char *path; Bool new,perm;
  1342.  
  1343. {
  1344.   char *fnp,*rval;
  1345.   fnp = (0 == (fnp = rindex(path,'/'))) ? path : fnp + 1;
  1346.   if (!new) return(fnp);
  1347.   if (!perm) {
  1348.      strcpy(pathbuffer,fnp);
  1349.      return(pathbuffer);
  1350.   }
  1351.   else {
  1352.      rval = emalloc(strlen(fnp) + 1);
  1353.      strcpy(rval,fnp);
  1354.      return(rval);
  1355.   }
  1356. }
  1357.  
  1358.  
  1359.  
  1360. read_yes_or_no (iport,oport,prompt,helpstring,quitstring)
  1361.  
  1362.   /* prints prompt, then reads from port until it gets 'Y', 'N', 'YES' or */
  1363.   /* 'NO' (case independently).  If helpstring and/or quitstring are not */
  1364.   /* "" or (char *) 0 then if the user types in one of those ANSWER_HELP */
  1365.   /* or ANSWER_QUIT are returned, otherwise ANSWER_NO or ANSWER_YES are */
  1366.   /* eventually returned. */
  1367.  
  1368.   FILE *iport, *oport;
  1369.   char *prompt, *helpstring, *quitstring;
  1370.  
  1371. {
  1372.   char buffer[20],buffer2[20];
  1373.   int bl,hl,ql,len;
  1374.   
  1375.   buffer[19] = '\0';
  1376.   
  1377.   while (T) {
  1378.         
  1379.     fprintf(oport,"%s",prompt);
  1380.     switch (len = getline(iport,buffer,20)) {
  1381.       case (AT_EOF) :
  1382.         return(ANSWER_EOF);
  1383.         break;
  1384.       case (TOO_MANY_CHARS) :
  1385.         break;
  1386.       default :
  1387.         if (0 == (bl = remove_excess_blanks(buffer2,buffer))) break;
  1388.         switch (yes_or_no_check(buffer2)) {
  1389.           case (0) :
  1390.             return(ANSWER_NO);
  1391.           case (1) :
  1392.             return(ANSWER_YES);
  1393.           case (-1) :
  1394.             if (helpstring != (char *) 0 && (hl = strlen(helpstring)) > 0) {
  1395.                if (0 == nocase_compare(buffer2,bl,helpstring,hl)) {
  1396.                   return(ANSWER_HELP);
  1397.                }
  1398.             }
  1399.             if (quitstring != (char *) 0 && (ql = strlen(quitstring)) > 0) {
  1400.                if (0 == nocase_compare(buffer2,bl,quitstring,ql)) {
  1401.                   return(ANSWER_QUIT);
  1402.                }
  1403.             }
  1404.             break;
  1405.         }   
  1406.         break;
  1407.     }
  1408.    
  1409.     fprintf(oport,"Please answer 'YES' or 'NO'\n");
  1410.     continue;
  1411.    
  1412.   }
  1413.     
  1414. }
  1415.  
  1416.  
  1417. int getline (iport,buffer,buflen) FILE *iport; char *buffer; int buflen;
  1418.  
  1419.   /* reads a line into buffer.  Does not put the '\n' into buffer. */
  1420.   /* Returns AT_EOF if at end of file when called.  If it encounters */
  1421.   /* end of file after reading at least one character, the eof is treated */
  1422.   /* as if it were a newline.   Returns TOO_MANY_CHARS if more than */
  1423.   /* buflen - 1 characters are read before encountering a newline. */        
  1424.   /* In this case exactly buflen - 1 characters are read. */
  1425.   /* The last character read is always follwed by a '\0'. */
  1426.   /* if successful getline returns the number of characters read exclusive */
  1427.   /* of a terminating newline or eof. */
  1428.  
  1429. {
  1430.   int ch;
  1431.   char *bptr = buffer;
  1432.   int nchars = 0;
  1433.   
  1434.   if (buflen <= 0) return(TOO_MANY_CHARS);
  1435.   
  1436.   while (T) {
  1437.     switch (ch = getc(iport)) {
  1438.       case (EOF) :
  1439.       case ('\n') :
  1440.         if (ch == EOF && nchars == 0) return(AT_EOF);
  1441.         *bptr = '\0';
  1442.         return(nchars);
  1443.       default :
  1444.         if (++nchars == buflen) { 
  1445.            *bptr = '\0';
  1446.            ungetc(ch,iport);
  1447.            return(TOO_MANY_CHARS);
  1448.         }
  1449.         *bptr++ = ch;
  1450.     }
  1451.     
  1452.   }
  1453.     
  1454. }
  1455.  
  1456.  
  1457. int getlines (fp,n,ptr_lines,linebuf,maxlinelen)
  1458.  
  1459.   /* See documentation for getfile below */
  1460.  
  1461.   FILE *fp;
  1462.   int n;
  1463.   char ***ptr_lines;
  1464.   char *linebuf;
  1465.   int maxlinelen;
  1466.  
  1467. {
  1468.   int len;
  1469.   char *line;
  1470.   if (0 > (len = getline(fp,linebuf,maxlinelen))) {
  1471.      if (len == AT_EOF) {
  1472.         *ptr_lines = (char **) emalloc(n * sizeof(char **));
  1473.         return(n);
  1474.      }
  1475.      else {
  1476.         return(TOO_MANY_CHARS);
  1477.      }
  1478.   }
  1479.   else {
  1480.      line = emalloc(len+1);
  1481.      strcpy(line,linebuf);
  1482.      len = getlines(fp,n+1,ptr_lines,linebuf,maxlinelen);
  1483.      if (len == TOO_MANY_CHARS) return(TOO_MANY_CHARS);
  1484.      (*ptr_lines)[n] = line;
  1485.      return(len);
  1486.   }
  1487. }
  1488.  
  1489.  
  1490. int getfile (filename,ptr_lines,linebuf,maxlinelen)
  1491.  
  1492.   /* read in a file as an array of character strings */
  1493.   /* 'maxlinelen+1' is the maximum length a line of the file is allowed */
  1494.   /* to be.  'linebuf' must be at least 'maxlinelen+1' characters long. */
  1495.   /* Returns the number of lines in the file (and therefore the number */
  1496.   /* of entries in *ptr_lines) if successful.  Returns IOERROR if it */
  1497.   /* could not open the file to read from. Returns TOO_MANY_CHARS if */
  1498.   /* it encounters a line longer than 'maxlinelen' characters. */
  1499.  
  1500.   /* Space for each line is malloc'ed as it is read in and the text for */
  1501.   /* the jth line is stored in (*ptr_lines)[j] */
  1502.  
  1503.   char *filename;
  1504.   char ***ptr_lines;
  1505.   char *linebuf;
  1506.   int maxlinelen;
  1507.  
  1508. {
  1509.   FILE *fp;
  1510.   int nlines;
  1511.   if (NULL == (fp = fopen(filename,"r"))) return(IOERROR);
  1512.   nlines = getlines(fp,0,ptr_lines,linebuf,maxlinelen);
  1513.   fclose(fp);
  1514.   return(nlines);
  1515. }
  1516.  
  1517.  
  1518. int ngetlines (fp,n,ptr_lines,linebuf,maxlinelen)
  1519.  
  1520.   /* See documentation for ngetfile below */
  1521.  
  1522.   FILE *fp;
  1523.   int n;
  1524.   char ***ptr_lines;
  1525.   char *linebuf;
  1526.   int maxlinelen;
  1527.  
  1528. {
  1529.   int len;
  1530.   int nlines = 0;
  1531.   *ptr_lines = (char **) emalloc(n * sizeof(char **));
  1532.   while (T) {
  1533.     if (0 > (len = getline(fp,linebuf,maxlinelen))) {
  1534.        if (len == AT_EOF) {
  1535.           return(nlines);
  1536.        }
  1537.        else {
  1538.           return(TOO_MANY_CHARS);
  1539.        }
  1540.     }
  1541.     else {
  1542.        if (++nlines > n) {
  1543.           return(TOO_MANY_LINES);
  1544.        }
  1545.        (*ptr_lines)[nlines-1] = anewstr(linebuf);
  1546.     }
  1547.   }
  1548. }
  1549.  
  1550.  
  1551.  
  1552. int ngetfile (n,filename,ptr_lines,linebuf,maxlinelen)
  1553.  
  1554.   /* Same as getfile except that at most n lines will be read. */
  1555.   /* If it attempts to read more than n lines, TOO_MANY_LINES will */
  1556.   /* be returned. */
  1557.  
  1558.   int n;
  1559.   char *filename;
  1560.   char ***ptr_lines;
  1561.   char *linebuf;
  1562.   int maxlinelen;
  1563.  
  1564. {
  1565.   FILE *fp;
  1566.   int nlines;
  1567.   if (NULL == (fp = fopen(filename,"r"))) return(IOERROR);
  1568.   nlines = ngetlines(fp,n,ptr_lines,linebuf,maxlinelen);
  1569.   fclose(fp);
  1570.   return(nlines);
  1571. }
  1572.  
  1573.  
  1574. extern int read_file_into_buffer (
  1575.  
  1576.        filename,ptr_lines,maxlines,buffer,buflen,linebuffer,linebuflen
  1577.  
  1578.     )
  1579.        
  1580.   char *filename; 
  1581.   char ***ptr_lines;
  1582.   int maxlines;
  1583.   char *buffer;
  1584.   int buflen;
  1585.   char *linebuffer;
  1586.   int linebuflen;
  1587.  
  1588.   /* *ptr_lines should be an array of character string pointers maxlines */
  1589.   /* big.  buffer should be an array of characters buflen long.  The routine */
  1590.   /* reads lines using getline and stores them into buffer, terminating each */
  1591.   /* with a null.  A pointer to the nth line read is stored in *ptr_lines[n] */
  1592.   /* Returns IOERROR if it cannot open the file for reading, TOO_MANY_LINES */
  1593.   /* if more than maxlines were read in, TOO_MANY_CHARS if buffer is */
  1594.   /* filled before end of file is reached, and LINE_TOO_LONG is any line is */
  1595.   /* longer than linebuflen.  Returns number of lines read in if successful. */
  1596.   
  1597. {  
  1598.   FILE *fp;
  1599.   int linecount,charcount,len;
  1600.   char *bp;
  1601.   char **lines;
  1602.   
  1603.   if (NULL == (fp = fopen(filename,"r"))) return(IOERROR);
  1604.   linecount = 0;
  1605.   charcount = 0;
  1606.   bp = buffer;
  1607.   lines = *ptr_lines;
  1608.   
  1609.   while (T) {
  1610.         
  1611.     if (0 > (len = getline(fp,linebuffer,linebuflen))) {
  1612.        fclose(fp);
  1613.        if (len == AT_EOF) {
  1614.           return(linecount);
  1615.        }
  1616.        else {
  1617.           return(LINE_TOO_LONG);
  1618.        }
  1619.     }
  1620.     
  1621.     if (linecount >= maxlines) {
  1622.        fclose(fp);
  1623.        return(TOO_MANY_LINES);
  1624.     }
  1625.     
  1626.     charcount += len;
  1627.     if (charcount >= buflen) {
  1628.        fclose(fp);
  1629.        return(TOO_MANY_CHARS);
  1630.     }
  1631.     
  1632.     strcpy(bp,linebuffer);
  1633.     lines[linecount++] = bp;
  1634.     bp += (len + 1);
  1635.   
  1636.   }
  1637.   
  1638. }
  1639.   
  1640. extern char *efopen (filename,mode) char *filename; char *mode;
  1641.  
  1642.   /* The routine simply calls fopen with the same arguments, but prints a */
  1643.   /* reasonable error message and calls exit if the call to fopen fails. */
  1644.  
  1645. {
  1646.   FILE *fp;
  1647.   if (NULL == (fp = fopen(filename,mode))) {
  1648.      fprintf(stderr,"Could not open %s, mode: %s\n",filename,mode);
  1649.      perror("Reason: ");
  1650.      exit(1);
  1651.   }
  1652.   return((char *) fp);
  1653. }
  1654.  
  1655.  
  1656. Bool check_string (s,minlen,maxlen) char *s; long minlen,maxlen;
  1657. {
  1658.   long len;
  1659.   if (s == 0) return(F);
  1660.   len = strlen(s);
  1661.   return (len >= minlen && len <= maxlen);
  1662. }
  1663.  
  1664. SHAR_EOF
  1665. if test 19032 -ne "`wc -c < 'ctools.c'`"
  1666. then
  1667.     echo shar: error transmitting "'ctools.c'" '(should have been 19032 characters)'
  1668. fi
  1669. fi
  1670. echo shar: extracting "'errors.c'" '(4039 characters)'
  1671. if test -f 'errors.c'
  1672. then
  1673.     echo shar: will not over-write existing file "'errors.c'"
  1674. else
  1675. cat << \SHAR_EOF > 'errors.c'
  1676. #include <stdio.h>
  1677. #ifdef TMC
  1678. #include <ctools.h>
  1679. #else
  1680. #include "ctools.h"
  1681. #endif
  1682. #include "texchk.h"
  1683.  
  1684.  
  1685. print_error_line ()
  1686. {
  1687.   int j;        
  1688.   fprintf(stderr,"Error on line number %d\n",Current_Line);        
  1689.   fprintf(stderr,"\n%s\n",Line_Buffer);
  1690.   for (j = 0; j < Current_Char-1; j++) fprintf(stderr," ");
  1691.   fprintf(stderr,"^\n\n");
  1692. }
  1693.  
  1694.  
  1695. eof_error ()
  1696. {  
  1697.   fprintf(stderr,"\nActual end of file before logical end of input.\n");
  1698.   fprintf(stderr,"Current environment:\n");
  1699.   print_stack();
  1700. }
  1701.  
  1702. stack_empty_error (etype,keyword) envtype etype; char *keyword;
  1703.  
  1704. {
  1705.   char *s, *e;
  1706.   switch (etype) {
  1707.     case ESCAPE_END :
  1708.       s = "\\begin";
  1709.       e = "\\end";
  1710.       break;
  1711.     case RIGHT_SQUARE_BRACKET :
  1712.       s = "[";
  1713.       e = "]";
  1714.       break;
  1715.     case RIGHT_CURLY_BRACKET :
  1716.       s = "{";
  1717.       e = "}";
  1718.       break;
  1719.     default :
  1720.       if (*keyword == ')') {
  1721.          s = "\\(";
  1722.          e = "\\)";
  1723.          break;
  1724.       }
  1725.       else if (*keyword == ']') {
  1726.          s = "\\[";
  1727.          e = "\\]";
  1728.          break;
  1729.       }
  1730.       fprintf(stderr,"Impossible etype argument to stack_empty_error\n");
  1731.       exit(1);
  1732.   }
  1733.   fprintf(stderr,"\nNo matching %s to go with %s\n",s,e);
  1734.   print_error_line();
  1735. }
  1736.  
  1737.  
  1738. no_brace_after_begin_end_error ()
  1739. {
  1740.   fprintf (
  1741.      stderr,
  1742.      "\n'\\begin' or '\\end' construct has no '{' immediately following\n"
  1743.    );
  1744.   print_error_line();
  1745. }
  1746.  
  1747. warning_blanks_in_cb ()
  1748. {  
  1749.   fprintf(stderr,"\nWarning:  probable error.\n");        
  1750.   fprintf(stderr,"LaTeX does not like initial or terminating blanks\n");
  1751.   fprintf(stderr,"inside of \\begin{} or \\end{} constructs\n");
  1752.   print_error_line();
  1753. }
  1754.  
  1755. warning_close_brace () 
  1756. {
  1757.   fprintf(stderr,"\nWarning:  texchk cannot handle environment names that\n");
  1758.   fprintf(stderr,"span more than one line...\n");
  1759.   print_error_line();
  1760. }  
  1761.  
  1762. bad_char_error (ch,abort) int ch; Bool abort;
  1763. {
  1764.   fprintf(stderr,"\nIllegal character: integer value = %d\n",ch);
  1765.   print_error_line();
  1766.   if (abort) exit(1);
  1767. }  
  1768.  
  1769. line_too_long_error ()
  1770. {
  1771.   fprintf(stderr,"\nToo many characters: line = %d\n",Current_Line);
  1772. }
  1773.  
  1774. blank_begin_end_error ()
  1775. {
  1776.   fprintf(stderr,"\nNo environment defined in '\\begin{}' or '\\end{}'\n");
  1777.   print_error_line();
  1778. }
  1779.  
  1780. keyword_error (keyword) char *keyword;
  1781. {
  1782.   fprintf(stderr,"\nWarning: unrecognized command name: \\%s\n",keyword);
  1783.   print_error_line();
  1784. }
  1785.  
  1786. math_keyword_error (keyword) char *keyword;
  1787. {
  1788.   fprintf (
  1789.       stderr,
  1790.       "\nError: 'Math mode only' command used outside math mode: \\%s\n",
  1791.       keyword
  1792.    );
  1793.    print_error_line();
  1794. }
  1795.  
  1796.  
  1797. nest_error (s,e,oldlinenum,current_key) 
  1798.   char *s, *e;
  1799.   int oldlinenum;
  1800.   char *current_key;
  1801. {
  1802.   fprintf(stderr,"\nNo matching %s for %s at current nesting level\n",s,e);
  1803.   print_error_line();
  1804.   fprintf (
  1805.      stderr,"Current nesting is '%s' at line %d\n",current_key,oldlinenum
  1806.    );
  1807. }
  1808.  
  1809.  
  1810. keyword_length_error ()
  1811. {
  1812.   fprintf(stderr,"\nLaTeX command too long\n");
  1813.   print_error_line();
  1814. }
  1815.  
  1816.  
  1817. single_char_command_error (ch) char ch;
  1818. {
  1819.   fprintf(stderr,"\nThe command \\%c is not legal LaTeX\n",ch);
  1820.   print_error_line();
  1821. }
  1822.  
  1823.  
  1824. print_stack ()
  1825.  
  1826. {
  1827.   int j;        
  1828.   fprintf(stderr,"\n\nTEXCHK ENVIRONMENT STACK:\n\n");
  1829.   for (j = 0; j <= Lex_TOS; j++) {
  1830.       switch (Lex_Stack[j].etype) {
  1831.         case ESCAPE_BEGIN :
  1832.           fprintf(stderr,"\\begin{%s}\n",Lex_Stack[j].keyword);
  1833.           break;
  1834.         case LEFT_SQUARE_BRACKET :
  1835.           fprintf(stderr,"[\n");
  1836.           break;
  1837.         case LEFT_CURLY_BRACKET :
  1838.           fprintf(stderr,"{\n");
  1839.           break;
  1840.         case MATH :
  1841.           fprintf(stderr,"Math Mode: %s\n",Lex_Stack[j].keyword);
  1842.           break;
  1843.         case DOUBLE_MATH :
  1844.           fprintf(stderr,"Display Math Mode\n");
  1845.           break;
  1846.         default :
  1847.           fprintf(stderr,"Stack corrupted...\n");
  1848.           texit();
  1849.       }
  1850.   }
  1851.   fprintf(stderr,"\n");
  1852. }
  1853.  
  1854.  
  1855. eof_verbatim_error ()
  1856. {
  1857.   fprintf(stderr,"\nError: EOF in middle of verbatim/verb environment\n");
  1858. }
  1859.  
  1860.  
  1861. verb_error (ch) char ch;
  1862. {
  1863.   fprintf(stderr,"Error: Illegal character after \\verb command: %c\n",ch);
  1864.   print_error_line();
  1865. }
  1866. SHAR_EOF
  1867. if test 4039 -ne "`wc -c < 'errors.c'`"
  1868. then
  1869.     echo shar: error transmitting "'errors.c'" '(should have been 4039 characters)'
  1870. fi
  1871. fi
  1872. echo shar: extracting "'texchars.c'" '(599 characters)'
  1873. if test -f 'texchars.c'
  1874. then
  1875.     echo shar: will not over-write existing file "'texchars.c'"
  1876. else
  1877. cat << \SHAR_EOF > 'texchars.c'
  1878. #include "texchars.h"
  1879.  
  1880. static char *Latex_Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:;,?!`'()[]-/*@#$%&~_^\\{}+=|<>\"\t \n";
  1881.  
  1882. static char *Lgl_Command_Chars = " !\"#$%&'()+,-./:;<=>@[\\]^_`{|}~";
  1883.  
  1884. char Lgl_Chars[256];
  1885. char Lgl_Single_Char_Commands[256];
  1886.  
  1887. init_legal_chars () 
  1888. {
  1889.   int j;
  1890.   char *lc = Latex_Chars;
  1891.   char *ls = Lgl_Command_Chars;
  1892.   for (j = 0; j < 256; j++) { 
  1893.       Lgl_Chars[j] = 0;
  1894.       Lgl_Single_Char_Commands[j] = 0;
  1895.   }
  1896.   while (*lc != '\0') Lgl_Chars[*lc++] = '1';  
  1897.   while (*ls != '\0') Lgl_Single_Char_Commands[*ls++] = '1';  
  1898.   return(1);
  1899. }
  1900. SHAR_EOF
  1901. if test 599 -ne "`wc -c < 'texchars.c'`"
  1902. then
  1903.     echo shar: error transmitting "'texchars.c'" '(should have been 599 characters)'
  1904. fi
  1905. fi
  1906. echo shar: extracting "'verbatim.c'" '(2479 characters)'
  1907. if test -f 'verbatim.c'
  1908. then
  1909.     echo shar: will not over-write existing file "'verbatim.c'"
  1910. else
  1911. cat << \SHAR_EOF > 'verbatim.c'
  1912. #include <stdio.h>
  1913. #include <ctype.h>
  1914.  
  1915. #ifdef TMC
  1916. #include <ctools.h>
  1917. #else
  1918. #include "ctools.h"
  1919. #endif
  1920.  
  1921. #include "texchk.h"
  1922.  
  1923. extern Bool Verbose_Mode;
  1924.  
  1925. do_verbatim (keyword) char *keyword;
  1926. {
  1927.   if (0 == strcmp("verbatim",keyword))
  1928.      find_end_verbatim("\\end{verbatim}");
  1929.   else if (0 == strcmp("verbatim*",keyword))        
  1930.      find_end_verbatim("\\end{verbatim*}");
  1931.   else {
  1932.      fprintf(stderr,"Fatal error, bad argument to do_verbatim: %s\n",keyword);
  1933.      exit(1);
  1934.   }
  1935.   if (Verbose_Mode) {
  1936.      do_indent(--Indent_Level);
  1937.      fprintf(stderr,"line %d: \\end{%s}\n",Current_Line,keyword);
  1938.   }
  1939. }
  1940.  
  1941.  
  1942. do_verb () 
  1943.  
  1944. /* get the next character after the 'verb' or 'verb*' command, then read */
  1945. /* until we find that character again. */
  1946.  
  1947. {
  1948.   char endchar[2];
  1949.   int ch;
  1950.   ch = get_a_char();
  1951.   if (ch == EOF) {
  1952.      eof_verbatim_error();
  1953.      exit(1);
  1954.   }
  1955.   else if (isalpha(ch) || ch == '*' || ch == ' ' || ch == '\n') {
  1956.      verb_error(ch);
  1957.      exit(1);
  1958.   }
  1959.   endchar[0] = ch;
  1960.   endchar[1] = '\0';
  1961.   find_end_verbatim(endchar);
  1962. }
  1963.  
  1964.  
  1965. find_end_verbatim (matchstring) char *matchstring;
  1966.  
  1967. /* Read characters until the exact characters constituting matchstring show */
  1968. /* up in the input stream, then return.  Matchstring may not contain '\n' */
  1969.  
  1970. {
  1971.   static char Verbatim_Buffer[MAXLL];
  1972.   char *vbptr;
  1973.   int j,ch;
  1974.   int matchlen;
  1975.   
  1976.   matchlen = strlen(matchstring);
  1977.   
  1978.   /* matches cannot span lines, since matchstring cannot contain '\n' */
  1979.   
  1980.   newline:
  1981.   
  1982.   for (j = 0; j < MAXLL; j++) Verbatim_Buffer[j] = '\0';
  1983.   vbptr = Verbatim_Buffer; 
  1984.   
  1985.   /* Nothing can possibly match until we have read in as many characters as */
  1986.   /* there are in matchstring, so read that many in. */
  1987.   
  1988.   for (j = 0; j < matchlen; j++) {
  1989.       switch (ch = get_a_char()) {
  1990.         case '\n' :
  1991.           goto newline;
  1992.           break;
  1993.         case EOF :
  1994.           eof_verbatim_error();
  1995.           exit(1);
  1996.           break;
  1997.         default :
  1998.           Verbatim_Buffer[j] = ch;
  1999.           break;
  2000.       }
  2001.   }
  2002.  
  2003.   /* check for a match, then read in the next character.  Keep checking */
  2004.   /* for a match against the last 'matchlen' characters. */
  2005.   
  2006.   j = matchlen;
  2007.   while (1) {
  2008.     if (0 == strcmp(matchstring,vbptr)) {
  2009.        return(1);
  2010.     }
  2011.     switch (ch = get_a_char()) {
  2012.       case '\n' :
  2013.         goto newline;
  2014.         break;
  2015.       case EOF :
  2016.         eof_verbatim_error();
  2017.         exit(1);
  2018.         break;
  2019.       default :
  2020.         Verbatim_Buffer[j] = ch;
  2021.         break;
  2022.     }
  2023.     j++;
  2024.     vbptr++;
  2025.   }
  2026. }
  2027. SHAR_EOF
  2028. if test 2479 -ne "`wc -c < 'verbatim.c'`"
  2029. then
  2030.     echo shar: error transmitting "'verbatim.c'" '(should have been 2479 characters)'
  2031. fi
  2032. fi
  2033. exit 0
  2034. #    End of shell archive
  2035.